//
//  QXMyselfVC.m
//  QXBlog
//
//  Created by QinXin on 15/7/5.
//  Copyright © 2015年 labi3285_Lab. All rights reserved.
//

#import "QXMyselfVC.h"
#import "QXNetworking.h"
#import "QXAccount.h"
#import "QXUser.h"
#import <SVProgressHUD/SVProgressHUD.h>


@interface QXMyselfVC ()

@end

@implementation QXMyselfVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self getSharedUser];
}


/// 进一步获取用户数据
- (void)getSharedUser {
    
    
    NSDictionary *params = @{
                             @"access_token": [QXAccount sharedAccount].access_token,
                             @"uid": [QXAccount sharedAccount].uid,
                             };
    
    [SVProgressHUD show];
    
    [[QXNetworking sharedNetworking] GET:@"2/users/show.json" parameters:params success:^(NSURLSessionDataTask *task, id dic) {
        
        NSLog(@"%@", dic);
        
        
        // 取得并创建用户模型数据
        QXUser *user = [QXUser userWithDic:dic];
        // 添加到单例归档路径
        [user achiveToSharedPath];
        
        [SVProgressHUD dismiss];
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        NSLog(@"---%@", error);
        [SVProgressHUD showErrorWithStatus:@"加载失败"];
    }];
    
}



@end
